package com.uzai.console.dto.device.deviceauth;

import com.uzai.console.common.utils.DateUtil;
import com.uzai.console.dto.QueryParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author liuqi
 * @date 2021年08月26日 14:31
 */
@ApiModel("机器人授权列表查询参数")
public class DeviceAuthQuery extends QueryParam {

    @ApiModelProperty("机器人类型key,必须有，因为要SQL外连接设备表")
    private String deviceType;

    @ApiModelProperty("查询类型(0-查询已经到期；1-查询未到期；2-查询即将到期（7天内)；3-查询即将到期（15天内)；4-查询即将到期（30天内)")
    private Integer expireType;

    @ApiModelProperty("查询开始到期时间")
    private Integer expireTimeStart;

    @ApiModelProperty("查询开始到期时间")
    private Integer expireTimeEnd;

    @ApiModelProperty("设备产品编码")
    private String productCode;

    @ApiModelProperty("设备微信号")
    private String deviceId;

    @ApiModelProperty("设备类型Id（0-电脑端；1-移动端）")
    private Integer deviceTypeId;

    @ApiModelProperty("是否关联设备表(0-不关联；1-关联)")
    private Integer relateDeviceFlag;

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public Integer getExpireType() {
        return expireType;
    }

    public void setExpireType(Integer expireType) {
        this.expireType = expireType;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public Integer getExpireTimeStart() {
        if(expireType != null) {
            if (expireTimeStart == null) {
                expireTimeStart = DateUtil.getNowTime();
            }
        }
        return expireTimeStart;
    }

    public void setExpireTimeStart(Integer expireTimeStart) {
        this.expireTimeStart = expireTimeStart;
    }

    public Integer getExpireTimeEnd() {
        if(expireType != null){
            if(expireType.intValue() == 0){
                expireTimeEnd = getExpireTimeStart();
            }else if(expireType.intValue() == 1){
                expireTimeEnd = getExpireTimeStart();
            }else if (expireType.intValue() == 2){
                expireTimeEnd = getExpireTimeStart() + 604800;
            }else if (expireType.intValue() == 3){
                expireTimeEnd = getExpireTimeStart() + 1296000;
            }else if (expireType.intValue() == 4){
                expireTimeEnd = getExpireTimeStart() + 2592000;
            }
        }
        return expireTimeEnd;
    }

    public void setExpireTimeEnd(Integer expireTimeEnd) {
        this.expireTimeEnd = expireTimeEnd;
    }


    public Integer getDeviceTypeId() {
        return deviceTypeId;
    }

    public void setDeviceTypeId(Integer deviceTypeId) {
        this.deviceTypeId = deviceTypeId;
    }

    public Integer getRelateDeviceFlag() {
        if(relateDeviceFlag == null){
            relateDeviceFlag = 0;
        }
        return relateDeviceFlag;
    }

    public void setRelateDeviceFlag(Integer relateDeviceFlag) {
        this.relateDeviceFlag = relateDeviceFlag;
    }
}
